﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using My.Data.Factories;
using My.Data.BusinessObject;
using My.Data.DataAccess;

namespace NHibernate.App
{
    public class LoginChecker
    {
        private ILoginDao loginDao = DataAccessFactory.LoadLoginDao();

        public static string check(Login login, IList<Login> loginList)
        {
            foreach (Login log in loginList)
            {
                if (log.UserName.Equals(login.UserName) && log.PassWord.Equals(login.PassWord))
                {
                    if (login.Type == 1)
                    {
                        return "superuser";
                    }
                    else if (login.Type == 2)
                    {
                        return "teacher";
                    }
                    else
                    {
                        return "student";
                    }
                }
            }
            return "failed";
        }
    }
}